/*
 *     ManagerServiceImpl.java  Copyright (c) 2021. cc01cc. All rights reserved.
 *
 *     This file is part of e-commerce.
 *
 *     e-commerce is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Affero General Public License as published
 *     by the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     e-commerce is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Affero General Public License for more details.
 *
 *     You should have received a copy of the GNU Affero General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package service;

import dao.BasicDao;
import dao.ManagerDao;
import dao.ManagerDaoImpl;
import pojo.Manager_register;
import pojo.User_register;

import java.sql.Connection;


/**
 * @author cc01cc
 */
public class ManagerServiceImpl implements ManagerService{
    private ManagerDao managerDao;
    public ManagerServiceImpl(){
        managerDao = new ManagerDaoImpl();
    }

    @Override
    public Manager_register login(String managerName, String managerPwd){

        Connection connection = null;
        Manager_register manager = null;
        try{
            connection = BasicDao.getConnection();
            manager = managerDao.getLoginManager(connection, managerName);
            System.out.println(manager.getManager_name());
        }catch(Exception e){
            e.printStackTrace();
        }finally {
            BasicDao.closeResource(connection, null, null);
        }
        if(manager.getManager_pwd().equals(managerPwd)){
            return manager;
        }else {
            return null;
        }
    }
}
